/**
 * Zhz.net Inc.
 * Copyright (c) 2004-2010 All Rights Reserved.
 */
package com.zhz.lib.project.service.faq;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhz.lib.project.domain.news.Sortmap;
import com.zhz.lib.project.ibatis.dao.faq.FaqDAO;
import com.zhz.lib.project.ibatis.domain.faq.Faq;
import com.zhz.lib.project.service.news.NewsService;
import com.zhz.project.common.util.hibernate.BaseDAO;

/**
 *
 * @author Administrator
 * @version $Id: FaqService.java, v 0.1 Sep 16, 2010 7:57:37 AM Administrator Exp $
 */
@Service
public class FaqService {

    private static Logger  logger      = Logger.getLogger(NewsService.class);
    @Autowired
    private BaseDAO        baseDao;
    @Autowired
    private FaqDAO         faqDAO;

    // 常见问题类型
    private static Integer faqfatherid = 6;

    /**
     * 根据ID获取常见问题
     * 
     * @param id
     * @return
     */
    public Faq getFaqById(int id) {

        return faqDAO.getFaqById(id + "");
    }

    /**
     * 获取常见问题
     * 
     * 条件：<br/> 1、未被删除 ifDelete =0<br/> 2、审核通过aproveState=1<br/> 
     * 
     *
     * @param firstResult
     * @param maxResults
     * @return
     */
    public List<Faq> getAllFaq(int firstResult, int maxResults) {
        return faqDAO.getAllFaq(firstResult, maxResults);
    }

    @SuppressWarnings("unchecked")
    public List<Sortmap> getFaqType() {

        // 查询数据库，得到常见问题类型
        return (List<Sortmap>) baseDao.findbyorderlimit("Sortmap", "fatherId", Integer
            .toString(faqfatherid), "order by sortMapId ASC");
    }

}
